package com.green.web.freemarker;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.view.freemarker.FreeMarkerView;

import com.green.web.util.PermissionHelper;

import freemarker.template.SimpleHash;

public class FreeMarkerViewExt extends FreeMarkerView {
	@Override
	protected SimpleHash buildTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
		//方便在模板文件中应用${ctx}
		model.put("ctx", request.getContextPath());
		//方便在模板文件中应用${base} 默认情况下指向林路径/themes/default
		model.put("base", request.getContextPath() + "/themes/default");
		model.put("optCodes", PermissionHelper.getOperateCodes());
		return super.buildTemplateModel(model, request, response);
	}
}
